<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common">

<xsl:template name="PNENGINE">
    <xsl:param name="token.xml"/>
    <xsl:param name="username"/>
    
    <root>
        <engine-info>
            <user><xsl:value-of select="$username"/></user>
        </engine-info>
        <places>
            <xsl:for-each select="exsl:node-set($token.xml)//place">
                <data>
                    <xsl:attribute name="place">
                        <xsl:value-of select="@id"/>
                    </xsl:attribute>
                    <xsl:apply-template select="document(.)/data/*" />
                </data>
            </xsl:for-each>
        </places>
    </root>
</xsl:template>
<xsl:template match="processdata">
	<processdata>
        <xsl:attribute name="target_place">
            <xsl:value-of select="@target_place"/>
        </xsl:attribute>
        <xsl:attribute name="name">
            <xsl:value-of select="@name"/>
        </xsl:attribute>
        <xsl:attribute name="place_id">
            <xsl:value-of select="../../@id"/>
        </xsl:attribute>
	<xsl:copy-of select="*" />
	</processdata>
</xsl:template>
<xsl:template match="metadata">
	<metadata>
          <xsl:attribute name="target_place">
              <xsl:value-of select="@target_place"/>
          </xsl:attribute>
          <xsl:attribute name="name">
              <xsl:value-of select="@name"/>
          </xsl:attribute>
          <xsl:attribute name="place_id">
              <xsl:value-of select="../../@id"/>
          </xsl:attribute>
	  <xsl:copy-of select="*" />
	</metadata>
</xsl:template>
</xsl:stylesheet>
